#pragma once

#ifdef _WIN32
#include <windows.h>
#else
#include <csignal>
#endif
#include <condition_variable>
#include <mutex>

namespace anet {
	namespace utils {
		// signal system.
		class CSignal {
		public:
			CSignal();
			virtual ~CSignal() {}

		public:
			static void requestStop();
			static bool isSignaled();

#ifdef _WIN32
			static BOOL WINAPI ConsoleHandler(DWORD signal);
#else
			static void signalHandler(int signal);
#endif

		protected:
			static std::condition_variable m_cv;
			static std::mutex m_mtx;
			static bool m_stopRequested;
		};
	}
}